import { defineStore } from 'pinia'
import { TradeInter } from '@/types/other'

export interface AskState {
  user_type: string,
  hostApi: string,
  load_pdf_url: string,
  preserve_pdf_url: string,
  submit_pdf_url: string,
  get_trade_list_url: string,
  upload_image_url: string,
  type: string,
  record_id: string,
  group_id: string,
  sub_key: string,
  tradeList: TradeInter[]
}

export const useAskStore = defineStore('ask', {
  state: (): AskState => ({
    user_type: '',
    hostApi: '',
    load_pdf_url: '',
    preserve_pdf_url: '',
    submit_pdf_url: '',
    get_trade_list_url: '',
    upload_image_url: '',
    type: 'default',
    record_id: '0',
    group_id: '0',
    sub_key: '0',
    tradeList: [],
  }),

  getters: {

  },

  actions: {
    setObj(askState: AskState) {
      const { user_type, hostApi, load_pdf_url, preserve_pdf_url, submit_pdf_url, get_trade_list_url, upload_image_url, type, record_id, group_id, sub_key} = askState
      this.user_type = user_type
      this.hostApi = hostApi
      this.load_pdf_url = load_pdf_url
      this.preserve_pdf_url = preserve_pdf_url
      this.submit_pdf_url = submit_pdf_url
      this.get_trade_list_url = get_trade_list_url
      this.upload_image_url = upload_image_url
      this.type = type
      this.record_id = record_id
      this.group_id = group_id
      this.sub_key = sub_key
    },

    setTradeList(tradeList: TradeInter[]) {
      this.tradeList = tradeList
    },

  },
})